clc;
clear;

tic;
startTime = cputime;
pde = PDE_struct_2d(1);
vector_N = [2 4 8 16 32 64];
plot_type = 1;
basis_type = "P1";
if pde.err
    error_L2 = zeros(size(vector_N,2),1);
    error_H1 = zeros(size(vector_N,2),1);
end
for i = 1:size(vector_N,2)
    Nx = vector_N(i);
    Ny = Nx;
    mesh = Mesh_struct_2d(pde, Nx, Ny, basis_type);
    U = poisson_solver_2d(mesh, pde);
    if pde.err
        error_L2(i,1) = process_error_2d(mesh, pde, U, "L2");
        error_H1(i,1) = process_error_2d(mesh, pde, U, "H1");
    end
    if plot_type
        process_plot_2d(mesh, pde, U);
    end
    fprintf("完成%d/%d次\n", i, size(vector_N,2));
end
if pde.err
    process_convergence_2d(error_L2, vector_N);
    process_convergence_2d(error_H1, vector_N);
end
elapsedTOCTime = toc;
elapsedCPUTime = cputime - startTime;
disp(['Elapsed TOC time is ', num2str(elapsedTOCTime), ' seconds.']);
disp(['Elapsed CPU time is ', num2str(elapsedCPUTime), ' seconds.']);

